﻿using DevExpress.XtraNavBar;
using DevExpress.XtraTreeList;
using System.Windows.Forms;

namespace CXW.Core.Sharp.Gui
{
    class NavBarGroupExt : NavBarGroup
    {
        Codon codon = null;
        /// <summary>显示内容根据此属性获取资源文件</summary>
        public string Language { get; private set; }

        public NavBarGroupExt(Codon codon)
        {
            Language = codon.Properties["language"];
            this.codon = codon;
            GroupStyle = NavBarGroupStyle.ControlContainer;
            Tag = codon;

            UpdateText();
        }

        public TreeView TreeView { get; set; }
        public TreeList TreeList { get; set; }

        string ResourceServiceLanguage = "";
        /// <summary>更新UI显示文字</summary>
        public void UpdateText()
        {
            if (ResourceServiceLanguage != ResourceService.Language)
            {
                LoggingService.DebugFormatted("1 Name = {1},Text = {0}", Caption, Name);
                ResourceServiceLanguage = ResourceService.Language;
                Caption = LanguageHelper.GetText(codon);
                LoggingService.DebugFormatted("--2 Name = {1},Text = {0}", Caption, Name);
            }
        }
    }
}
